from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from user.models import MyUser
from django.utils.translation import gettext_lazy as _


# Register your models here.

# 自定义MyUserAdmin类,并继承ModelAdmin
@admin.register(MyUser)
class MyUserAdmin(UserAdmin):
    # 设置显示字段，用于admin后台数据的表头设置
    list_display = ['username', 'email', 'mobile', 'qq', 'weChat']
    # 将源码的UserAdmin.fieldsets转换成列表格式
    fieldsets = list(UserAdmin.fieldsets)
    # 重写UserAdmin的fieldsets，添加'mobile','qq','weChat'等信息的录入
    fieldsets[1] = (_('Personal info'), {'fields': ('first_name', 'last_name', 'email', 'mobile', 'qq', 'weChat')})
